package com.tianji.learning.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.tianji.common.enums.BaseEnum;
import lombok.Getter;

@Getter
public enum PointsRecordType implements BaseEnum {
//    LEARNING(1, "课程学习", 50),
//    SIGN(2, "每日签到", 0),
//    QA(3, "课程问答", 20),
//    NOTE(4, "课程笔记", 20),
//    COMMENT(5, "课程评价", 0),
//    ;
//    @EnumValue
//    @JsonValue
//    final int value;
//    final String desc;
//    final int maxPoints;
//
//    PointsRecordType(int value, String desc, int maxPoints) {
//        this.value = value;
//        this.desc = desc;
//        this.maxPoints = maxPoints;
//    }

    LEARNING(1, "课程学习"),
    SIGN(2, "每日签到"),
    QA(3, "课程问答"),
    NOTE(4, "课程笔记"),
    COMMENT(5, "课程评价");

    @EnumValue
    @JsonValue
    private final int value;
    private final String desc;

    // 移除 maxPoints 参数
    PointsRecordType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static PointsRecordType of(Integer value){
        if (value == null) {
            return null;
        }
        for (PointsRecordType status : values()) {
            if (status.equalsValue(value)) {
                return status;
            }
        }
        return null;
    }
}